package hexagon.security.core.domain;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;

import javax.persistence.*;
import java.util.List;

/**
 * @author XueguiYuan
 * @version 1.0 (created time: 2016/12/3).
 */
@NoArgsConstructor
@Getter
@Setter
@ToString(callSuper = true)
@Entity
@DiscriminatorValue("Role")
public class Role extends Authority {

    @ManyToMany(fetch = FetchType.EAGER)
    @JoinTable(name = "role_permission_map",
            joinColumns = @JoinColumn(name = "role_id"),
            inverseJoinColumns = @JoinColumn(name = "permission_id")
    )
    private List<Permission> permissions;

    public static final Finder<Long, Role> find = new Finder<>(Role.class);
}
